import { AuthGuard } from './../auth/auth.guard';
import { ManageHeroesComponent } from './manage-heroes/manage-heroes.component';
import { ManageCrisesComponent } from './manage-crises/manage-crises.component';
import { AdminDashboardComponent } from './admin-dashboard/admin-dashboard.component';
import { AdminComponent } from './admin/admin.component';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const adminRoutes: Routes = [
    {
      path:'',
      component:AdminComponent,
      // 在跳转之前加个身份验证
      canActivate:[AuthGuard],
      children:[
         {
          // 无组件路由，用于分组，层次更清晰，也可保护子路由
            path:'',
            // 表示对下面所有的孩子进行守卫
            canActivateChild:[AuthGuard],
            children:[
               { path:'', component:AdminDashboardComponent },

               { path:'crises', component:ManageCrisesComponent },

               { path:'heroes', component:ManageHeroesComponent },
            ]
         }
      ]
    }
];

@NgModule({
  imports: [RouterModule.forChild(adminRoutes)],
  exports: [RouterModule]
})
export class AdminRoutingModule { }
